/**
 * Created by Brook on 2019/2/25.
 */
(function(){
    const crypto = require('crypto');

    //校验用户登录状态
    const get_login_user=function(req,res,callback){
        if (!req.session.user) {
            res.redirect('/');
            return;
        } else {
            callback(req.session.user);
        }
    };
    exports.Get_Login_User = get_login_user;

    /**
     * crypto加密
     */
    const encryption= function (data){
        const key = 'Brook_API'
        const cipher = crypto.createCipher('aes192', key);
        let enc = cipher.update(data, 'utf8', 'hex');//编码方式从utf-8转为hex;
        enc += cipher.final('hex');//编码方式从转为hex;
        return enc;
    };
    exports.Encryption = encryption;

}).call(this);
